
# key1=value1&key2=value2

string = 'pageSize=30&product=EFund&DISCOUNT=&SortColumn=SYL_Y&MobileKey=4a69e1fc7d583fe671ad69c95ae6c2b7%7C%7C945235770232353&BUY=true&appType=ttjj&LevelOne=&version=6.3.2&onFundCache=3&Sort=desc&pageIndex=1&FundType=6&CompanyId=&plat=Android&TOPICAL=&ENDNAV=&LevelTwo=&ISABNORMAL=true&DataConstraintType=0&gToken=ceaf-236567466abfda4e2864831ea5645231&ESTABDATE=6&deviceid=4a69e1fc7d583fe671ad69c95ae6c2b7%7C%7C945235770232353'

def getKeyValuePairs(string):
    return string.split('&')

def generateDict(pairs):
    dict = {}
    for pair in pairs:
        items = pair.split('=')
        key = items[0]
        if len(items) ==1:
            dict[key] = None
        elif len(items) ==2:
            dict[key] = items[1]
    return dict



pairs = getKeyValuePairs(string)
dict = generateDict(pairs)

sorted_keys = sorted(dict.keys())

pairs = []
for key in sorted_keys:
    value = dict[key]
    pairs.append(key + '=' + value)

result = "&".join(pairs)
print(result)
